//导入封装后的 axios 实例对象
import {request} from '@utils/http';
import { HospitalSetItem, ReqAddHospitalSetParams, ReqGetHospitalSetParams, ReqGetHospitalSetResponse, ReqUpdateHospitalSetParams } from './model/hospitalSetTypes';
import { Key } from 'antd/lib/table/interface';
/**
 * 封装函数, 发送请求获取医院设置的列表
 */
export let reqGetHospitalSet = (args: ReqGetHospitalSetParams) => {
  //解构赋值
  let {page, limit, hoscode, hosname} = args;
  //发送请求
  return request.get<any, ReqGetHospitalSetResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
    params: {
      hosname: hosname,
      hoscode: hoscode
    }
  })
}

/**
 * 封装函数, 发送请求新增医院设置
 */
export let reqAddHospitalSet = (data: ReqAddHospitalSetParams) => {
  return request.post<any, null>('/admin/hosp/hospitalSet/save', data);
}

/**
 * 请求删除某个 id 的医院
 */
export let reqRemoveHospitalById = (id: Key) => {
  return request.delete<any, null>('/admin/hosp/hospitalSet/remove/' + id);
}

/**
 * 根据 id 获取医院的详细信息
 */
export let reqGetHospitalSetById = (id: Key) => {
  return request.get<any, HospitalSetItem>('/admin/hosp/hospitalSet/get/' + id);
}

/**
 * 更新医院的信息
 */
export let reqUpdateHospitalSet = (data: ReqUpdateHospitalSetParams) => {
  return request.put('/admin/hosp/hospitalSet/update', data);
}

/**
 * 根据 id 列表删除医院信息  Batch 批量
 */
export let reqBatchRemoveHospital = (data: Key[]) => {
  //发送请求
  return request.delete('/admin/hosp/hospitalSet/batchRemove', {
    data: data
  });
}
